import useAppStore from './appStore';
import useFlashStore from './flashStore';
import useTerminalStore from './terminalStore';
import useUserStore from './userStore';
import { useShallow } from 'zustand/react/shallow';

export { 
  useAppStore, 
  useFlashStore, 
  useTerminalStore, 
  useUserStore 
};

// 移除有类型问题的全局stores导出
// export const useGlobalStores = () => ({
//   app: useAppStore(),
//   flash: useFlashStore(),
//   terminal: useTerminalStore(),
//   user: useUserStore(),
// });

export const useTerminalActions = () => useTerminalStore(
  useShallow((state) => ({
    createLine: state.createLine,
    addOutput: state.addOutput,
    addOutputLine: state.addOutputLine,
    addErrorLine: state.addErrorLine,
    addWarningLine: state.addWarningLine,
    addSystemLine: state.addSystemLine,
    clearOutput: state.clearOutput,
    parseOutput: state.parseOutput,
    toggleVisibility: state.toggleVisibility,
    showTerminal: state.showTerminal,
    hideTerminal: state.hideTerminal,
  }))
);

export const useTerminalVisibility = () => useTerminalStore(
  useShallow((state) => ({
    isVisible: state.isVisible,
    toggleVisibility: state.toggleVisibility,
    showTerminal: state.showTerminal,
    hideTerminal: state.hideTerminal,
  }))
);

export const useFlashActions = () => useFlashStore(
  useShallow((state) => ({
    startFlash: state.startFlash,
    updateProgress: state.updateProgress,
    completeFlash: state.completeFlash,
    setError: state.setError,
    clearError: state.clearError,
    reset: state.reset,
  }))
);

export const useFlashState = () => useFlashStore(
  useShallow((state) => ({
    isFlashing: state.isFlashing,
    progress: state.progress,
    error: state.error,
  }))
);

export const useUserActions = () => useUserStore(
  useShallow((state) => ({
    login: state.login,
    logout: state.logout,
    clearError: state.clearError,
    initializeAuth: state.initializeAuth,
  }))
);

export const useUserState = () => useUserStore(
  useShallow((state) => ({
    isLoggedIn: state.isLoggedIn,
    userInfo: state.userInfo,
    loading: state.loading,
    error: state.error,
  }))
);
